<template>
    <div>

        <el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose"
            :collapse="isCollapse">
            <h4 >{{isCollapse?'导航':'后台管理系统'}}</h4>
            
            <el-menu-item @click="skipmenu(item)" v-for="(item, index) in noChildren" :key="index" :index="String(item.path)">
                <i :class="'el-icon-' + item.icon"></i>
                <span slot="title">{{ item.label }}</span>
            </el-menu-item>

           

        </el-menu>

    </div>
</template>

<script>
export default {
    data() {
        return {
            menu: [
 
            ]
        };
    },
    methods: {
        handleOpen() {
            // console.log(key, keyPath);
        },
        handleClose() {
            // console.log(key, keyPath);
        },
        skipmenu(item){
            this.$router.push({
                name:item.name
            })
            this.$store.commit('selectMenu',item)
        }
    },
    computed: {
        noChildren() {
            return this.asyncMenu.filter(item => !item.children
            )
        },
        haschildren() {
            return this.asyncMenu.filter(item => item.children
            )
        },
        isCollapse(){
            return this.$store.state.tab.isCollapse
           
        },
        asyncMenu(){
            return this.$store.state.tab.menu
        }
    }
}
</script>

<style lang="less" scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
    max-width: 200px;
     min-width: 70px;
    min-height: 400px;
}

  h4 {
         // color: #fff;
        text-align: center;
        line-height: 40px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: clip;
    }
    
</style>